<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
set_html('title','订单');
if($_RQ['op']=='main'){
	$return['params']=array('status'=>$_RQ['status']?intval($_RQ['status']):10);
	exi($return);
}
/*******op*******/
if($_RQ['op']=='list'){
	$list=pdo_getall('jy_yuejie_order',array('uniacid'=>$_SESSION['uniacid']));
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	//查询进入该页面的客户所有订单
	if($_RQ['isworker']){
		$params=array('yuejiemid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']);
	}else{
		$params=array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']);
	}
	if(isset($_RQ['status']) && $_RQ['status'] != 10){
		$params['status']=intval($_RQ['status']);
		$return['status']=$_RQ['status'];
	}else{
		$return['status']=10;
	}
	$list=pdo_getslice('jy_yuejie_order',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		foreach($list as &$item){
			$item['info']=model($item['plugin'].'/model')->getorder($item);
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			$item['member']=cfc('core')->member_show($item['mid']);
		}
	}
	$return['list']=$list;
	exi($return);
}
//订单详情
if($_RQ['op']=='detail'){
	if(!$_RQ['id']){
		exi('订单不存在，请重新选择','error');
	}
	$order=pdo_get('jy_yuejie_order',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	//用户信息
	$member=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$order['user_id']));
	$return['order']=$order;
	$return['member']=$member;
	exi($return);
}